package pers.baiban.sqltoword.handler.impl;

import pers.baiban.sqltoword.handler.AbstractTableProcessor;
import pers.baiban.sqltoword.handler.TableProcessor;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 表格竖条边框处理器
 *
 * @author 强子初
 * @since 2023/11/29
 */
@Component
@Order(5)
public class TableBorderInsideHProcessor extends AbstractTableProcessor implements TableProcessor {

    @Override
    public void doHandler() {
        if (needUpdate(param.getTableBorderInsideH())) {
            getInsideH().setVal(param.getTableBorderInsideH());
        }

        if(needUpdate(param.getTableBorderInsideHWidth())) {
            getInsideH().setSz(param.getTableBorderInsideHWidth());
        }
    }

    /**
     * 获取表格竖条边框
     */
    private CTBorder getInsideH() {
        return borders.isSetInsideH() ? borders.getInsideH() : borders.addNewInsideH();
    }
}